home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / dtbl11.zip / DEMO1.FRM (.txt) < prev    next >
Visual Basic Form  |  1993-05-10  |  10KB  |  190 lines

  1. Form1
  2. !DataTable Example Program - DEMO1
  3. wwwwwwwwwwwwwww
  4. wwwwwwwwwwwwwww
  5. Form1
  6. Customer
  7.     DATATABLE
  8. C:\CUSTOMER
  9. Label1
  10. Name:
  11. CustomerName
  12. Label2
  13. Address:
  14. Address
  15. Label3
  16. City:
  17. Label4
  18. State:
  19. State
  20. Label5
  21. Label6
  22. Phone:
  23. Phone
  24.     TopButton
  25. NextButton
  26. InsertButton
  27. Insert
  28. DeleteButton
  29. Delete
  30. QuitButton
  31. BottomButton
  32. Bottom
  33. PreviousButton
  34. Previous
  35. UpdateButton
  36. Update
  37. ClearButton
  38. Clear
  39. QuitButton_Click
  40. Form_Click
  41.     Form_Load>
  42. Customer
  43.     OpenTableg
  44. Action
  45. CloseTable%
  46. FillForm
  47.     GetRecord
  48.     FieldName
  49. GetField
  50. CustomerName:
  51. Text$
  52. FieldValue
  53. Address
  54. StateW
  55. Phone}
  56.     InsertRecW
  57. PutField
  58. InsertRecord
  59. InsertButton_Click
  60. ClearButton_Click
  61. TopButton_Click
  62. FirstRecord
  63. BottomButton_Click
  64. LastRecord
  65. NextButton_Click
  66. NextRecord
  67. PreviousButton_ClickJ
  68. PreviousRecord
  69. DeleteButton_Click
  70. DeleteRecord
  71.     UpdateRec
  72. UpdateRecord
  73. UpdateButton_Click
  74. Reaction
  75. DisplayError
  76. TheError
  77. Form_Unload
  78. Cancel
  79. Form_Load
  80. This code opens the database table (C:\CUSTOMER) and fills in the Visual Basic
  81. Form with the information present in the first record in the database.
  82. Open up the database table (Customer.TableName)e
  83. Fill the form 
  84. QuitButton_Click
  85. This code closes our database table and terminates the Demo programm
  86. Close the database table
  87. Terminate this demoe
  88. FillForm
  89. We need to get the current record in the database:
  90. Ok, now lets get the values in the database fields for the
  91. record we just read in::
  92. We need to make a one-to-one relationship between the fields in the database table
  93. and the fields on our Visual Basic Form. We will read in the field values from the
  94. database record and place those values into the .TEXT property of our TEXT controlss
  95. on our Visual Basic form. For each field of interest this is a three-step process:
  96. 1. Specify the name of the database field of interest ---> DataTable.FieldName = "
  97. 2. Get the field value ---> DataTable.Action = GetFieldd
  98. 3. Place the field value in the TEXT control ---> Text1.TEXT = DataTable.FieldValuee
  99. Thats all there is to it!!
  100. You should make a FillForm like subroutine position independent. Notice that the first line of
  101. code in this subroutine reads in the current record. Use other routines to move around
  102. in the table (like the TOP,BOTTOM, NEXT and PREVIOUS buttons in this demo). Making the
  103. routine position independent means that it can be used and re-used at any time to fill inn
  104. your form with information from any record in your database.
  105. We will fill in the form now:o
  106. Address"
  107. State"
  108. Phone"
  109. InsertRec
  110. Here we transfer the information from the Visual Basic Form and insert it
  111. into the database table.
  112. To do this requires a three-step process for each field in the database table:
  113. 1. Specify the name of the field of interest ---> DataTable.FieldNames
  114. 2. Specify the field value ---> DataTable.FieldValue = A String values
  115. 3. Put the field into the DataTable record ---> DataTable.Action = PutFieldl
  116. We do this for each field in the database table.
  117. When we are finished we INSERT the record into the
  118. database table ---> DataTable.Action = InsertRecord
  119. Address"
  120. State"
  121. Phone"
  122. InsertButton_Click
  123. ClearButton_Click
  124. This code simply clears the text in all of the Visual Basic form's Text controls..
  125. TopButton_Click
  126. The following code moves to the first record in the data basee
  127. and fills in our form with the information found in that first
  128. record
  129. BottomButton_Click
  130. The following code moves to the last record in the data base
  131. and fills in our form with the information found in that lastt
  132. record
  133. NextButton_Click
  134. The following code moves to the next record in the database table. If an
  135. error is encountered during the move to the next record an error message is displayed.
  136. The DisplayError subroutine is an example of the structure of a generalizedd
  137. DataTable error handling routine..
  138. Once the repositioning to the next record is successfull, we fill in our formm
  139. with information from that record.
  140. Moving to the next record in the databaseu
  141. If an error 
  142. Display the DataTable errore
  143. If no error
  144. Fill in our form with the information in the record.
  145. PreviousButton_Click
  146. The following code moves to the previous record in the database table. If an
  147. error is encountered during the move to the record an error message is displayed.a
  148. The DisplayError subroutine is an example of the structure of a generalized 
  149. DataTable error handling routine. 
  150. Once the repositioning to the previous record is successfull, we fill in our formm
  151. with information from that record.
  152. Moving to previous recordM
  153. If an errors
  154. Display the DataTable Error 
  155. If no error
  156. Fill in our form with info from the record
  157. DeleteButton_Click
  158. This code deletes the current record from the database
  159. The current record after the delete is performed, is the record immediatelyy
  160. following the deleted record. We then fill in our form with info from that
  161. record..
  162. We will delete the current record.
  163. Now fill in form with the current record.n
  164. UpdateRec
  165. Here we transfer the information from the Visual Basic Form and update the
  166. current record in the database table. 
  167. To do this requires a three-step process for each field in the database table:
  168. 1. Specify the name of the field of interest ---> DataTable.FieldNames
  169. 2. Specify the field value ---> DataTable.FieldValue = A String values
  170. 3. Put the field into the DataTable record ---> DataTable.Action = PutFieldl
  171. We do this for each field in the database table.
  172. When we are finished we UPDATE the record into the
  173. database table ---> DataTable.Action = UpdateRecordd
  174. Address"
  175. State"
  176. Phone"
  177. UpdateButton_Click
  178. DisplayError
  179. This code is an examle of a DataTable error handling routine..
  180. It is not a complete error routine but a small example intendedd
  181. to show how a DataTable error routine can be implemented..
  182. Drive not ready!
  183. Directory not found!
  184. File is busy!"
  185. File is Locked!"
  186. File not Found!"
  187. End of Table!"
  188. Start of Table!"
  189. Unknown Error!
  190.